package cpt202.project.util;
import java.io.Serializable;
//该类将信息进行一个封装，用于返回给前端，形式是二进制
public class JsonResult<E> implements Serializable {
    private int state;
    private String message;
    private E data;

    public JsonResult() {
    }

    public JsonResult(int state) {
        this.state = state;
    }

    public JsonResult(int state, E data) {
        this.state = state;
    }

    public JsonResult(Throwable e){
        this.message = e.getMessage();
    }

    public int getState() {
        return state;
    }

    public void setState(int state) {
        this.state = state;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public E getData() {
        return data;
    }

    public void setData(E data) {
        this.data = data;
    }

    @Override
    public String toString() {
        return "jsonResult{" +
                "state=" + state +
                ", message='" + message + '\'' +
                ", data=" + data +
                '}';
    }
}
